package com.itheima;

import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;

public class UserService {

    public Integer getAge(String idcard)
    {

        String birthday=idcard.substring(6,14);
        LocalDate parse=LocalDate.parse(birthday, DateTimeFormatter.ofPattern("yyyyMMdd"));
        return Period.between(parse,LocalDate.now()).getYears();

    }

    public String getGender(String idcard)
    {
        return Integer.parseInt(idcard.substring(16,17))%2==1?"男":"女";
    }


}
